<template>
  <div class="details-vip">
    <div class="text-center text-3xl font-black p-4">会员套餐权益</div>
    <div class="flex justify-center items-center text-xl p-b-4">
      <el-icon class="text-orange-400"><Select /></el-icon>支持
      <el-icon class="p-l-2"><CloseBold /></el-icon>不支持
    </div>
    <el-table
      v-loading="loading"
      :data="tableList"
      stripe
      row-key="id"
      :tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
      default-expand-all
    >
      <el-table-column prop="name" label="" fixed="left">
        <template #default="scope">
          <span :class="scope.row.parentId ? '' : 'font-black'">
            {{ scope.row.name }}</span
          >
        </template>
      </el-table-column>
      <el-table-column
        v-for="(column, index) in tableField"
        :key="index"
        :label="column.name"
        align="center"
        min-width="150"
        v-bind="column.options"
        ><!-- 
        :prop="column.keyValue" -->
        <template #default="scope">
          <div v-if="scope.row.parentId">
            <el-icon
              v-if="scope.row[column.keyValue] == 'true'"
              class="text-orange-400"
              ><Select
            /></el-icon>
            <el-icon
              v-else-if="
                scope.row[column.keyValue] == 'false' ||
                !scope.row[column.keyValue]
              "
              ><CloseBold
            /></el-icon>
            <span v-else class="text-orange-400">
              {{ scope.row[column.keyValue] }}</span
            >
          </div>
        </template>
      </el-table-column>
      <el-table-column prop="remark" label="备注" width="250" align="center">
      </el-table-column>
    </el-table>
  </div>
</template>
<script setup name="detailsVIP">
import { listEquity } from '@/api/rightsManage/index'
const { proxy } = getCurrentInstance()

// 接受父级传递的参数
const props = defineProps({
  param: {
    required: true,
    type: Object || Array,
    default: () => {
      return {}
    }
  }
})

const data = reactive({
  loading: false,
  tableField: [
    { keyValue: 'content', name: '标准版云财税会员' },
    { keyValue: 'content', name: '标准版云财税会员1' },
    { keyValue: 'content', name: '标准版云财税会员2' }
  ],
  tableList: [
    {
      name: '标准版云财税会员',
      content: 'true'
    },
    {
      name: '标准版云财税会员1',
      content: 'true'
    }
  ]
})
const { loading, tableField, tableList } = toRefs(data)
// 初始化
watch(
  () => props.param,
  async val => {
    console.log('val==>', val)
    if (Array.isArray(val)) {
      tableField.value = val.map(item => {
        return {
          name: item.name,
          keyValue: 'content'
        }
      })
      val.forEach(item => {
        tableList.value = [...item.equityList]
      })
    } else {
      tableField.value = [
        {
          name: val.name,
          keyValue: 'content'
        }
      ]
      tableList.value = [...val.equityList]
    }
  },
  {
    // flush: 'post'
    immediate: true,
    deep: true
  }
)
// 初始化
async function init() {
  // 归属部门
  // getList()
}

init()
</script>
<style scoped>
.search-drawer-retract {
  color: #999999;
}
</style>
